package com.sayice.icemusic.controller;

import com.sayice.icemusic.pojo.Music;
import com.sayice.icemusic.service.music.MusicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 音乐请求处理器
 *
 * @author shubing
 */
@RestController
@CrossOrigin("*")
@RequestMapping("/music")
public class MusicController {
    @Qualifier("musicServiceImpl")
    @Autowired
    MusicService musicService;
    
    /**
     * 搜索音乐
     */
    @GetMapping(value = "/search", produces = "application/json")
    public List<Music> search(String name, String sorter) {
        return musicService.search(name, sorter);
    }
    
    /**
     * 获取歌词
     */
    @GetMapping(value = "/lyric", produces = "application/json")
    public String[][] getLyrics(String musicId, String sourceName) {
        return musicService.getLyrics(musicId, sourceName);
    }
}
